
import ic.ast.Node;
import ic.ast.decl.*;

import java.util.HashMap;

public class LibraryParser extends BaseParser {
	
	// @formatter:off
	private final static String GRAMMAR =
		  "            S -> class_decl\n"
		+ "   class_decl -> class CLASS_ID { members } \n"
		+ "      members -> static_method members | \n"
		+ "static_method -> static weaktype ID ( opt_formals ) ;\n"
		+ "     weaktype -> type | void\n"
		+ "  opt_formals -> formals | \n"
		+ "      formals -> formal , formals | formal\n"
		+ "       formal -> type ID\n"
		+ "         type -> int | boolean | string | CLASS_ID | type [ ] \n";
	// @formatter:on
	
    public LibraryParser()
    {
        super(GRAMMAR);
    }

    @Override
    protected Node constructAst(fun.parser.Tree parseTree)
    {
    	return ((Program)(new RNodeS().recurse(parseTree, new HashMap<String, Functor>()))).getClasses().get(0);
    }
}
